﻿using System;
using System.Windows;

namespace MyChars
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        private void calclateRealWindowHeight()
        {
            double buttonWidth = (Double)FindResource("buttonSide");
            double margins = window1.ActualHeight - grid1.ActualHeight;
            double realHeight = Math.Ceiling(stack.Children.Count / 5.0) * buttonWidth;
            //
            window1.Height = margins + grid1.RowDefinitions[0].ActualHeight + grid1.RowDefinitions[1].ActualHeight + realHeight;
        }

        private void adjustWindowPosition()
        {
            double window1_Left = System.Windows.SystemParameters.PrimaryScreenWidth - window1.Width;
            double window1_Top = System.Windows.SystemParameters.PrimaryScreenHeight - window1.Height - (System.Windows.SystemParameters.PrimaryScreenHeight - System.Windows.SystemParameters.FullPrimaryScreenHeight);
            //
            if (this.Top > window1_Top)
            {
                this.Top = window1_Top;
            }
            if (this.Left > window1_Left)
            {
                this.Left = window1_Left;
            }
            //

        }

        private void PositionOnRightEdge()
        {
            //
            double buttonWidth = 23;
            double windowBorder = window1.Width - grid1.ActualWidth;
            //
            buttonWidth = (Double)FindResource("buttonSide");

#if false
            Style sb = TryFindResource("buttonWidth") as Style;
            if (null != sb)
            {
                foreach (Setter s in sb.Setters)
                {
                    if ("Width" == ((Setter)sb.Setters[0]).Property.Name)
                    {
                        buttonWidth=  (double)((Setter)sb.Setters[0]).Value;
                        break;
                    }
                }
                //((Button)sender).Style = FindResource("ButtonStyle") as Style;
            }
#endif
            //
            window1.Width = 5.0 * buttonWidth + windowBorder;
            //;
            window1.Left = System.Windows.SystemParameters.PrimaryScreenWidth - window1.Width;
            window1.Top = System.Windows.SystemParameters.PrimaryScreenHeight - window1.Height - (System.Windows.SystemParameters.PrimaryScreenHeight - System.Windows.SystemParameters.FullPrimaryScreenHeight);
        }





    }//class
}//namespace
